package com.mazaiting.redeye.module.friend.info

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import cn.jpush.im.android.api.model.UserInfo
import com.mazaiting.easy.app.IApplicationComponent
import com.mazaiting.easy.base.activity.BaseToolbarActivity
import com.mazaiting.redeye.R
import com.mazaiting.redeye.base.ApplicationComponentImpl
import java.io.Serializable

/**
 * 朋友信息页面
 */
class FriendInfoActivity : BaseToolbarActivity<FriendInfoPresenter>(), FriendInfoContract.View {

    companion object {
        /**
         * 用户信息
         */
        private const val KEY_USER_INFO = "key_user_info"

        /**
         * 新实例
         * @param context 上下文
         * @param userInfo 用户信息
         */
        fun newInstance(context: Context, userInfo: UserInfo) {
            val intent = Intent(context, FriendInfoActivity::class.java)
            intent.putExtra(KEY_USER_INFO, userInfo.toJson())
            context.startActivity(intent)
        }

    }

    /**
     * 用户信息
     */
    private var mUserInfo: UserInfo? = null

    override fun getContentLayout(): Int = R.layout.activity_friend_info

    override fun inject(applicationComponent: IApplicationComponent?) {
        DaggerFriendInfoComponent
            .builder()
            .applicationComponentImpl(applicationComponent as ApplicationComponentImpl)
            .build()
            .inject(this)
    }

    override fun initData() {
        // 获取姓名
        val info = intent.getStringExtra(KEY_USER_INFO)
        // 转换用户信息
        mUserInfo = UserInfo.fromJson(info)

        setUserInfo()
    }

    /**
     * 设置用户信息
     */
    private fun setUserInfo() {

    }

}
